﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Reflection;
using IDAL;

namespace DALFactory
{
    /// <summary>
    /// DAL 抽象工厂模式的实现
    /// 从配置文件获取DAL所在的命名空间
    /// </summary>
    public sealed class DataAccess
    {
        //从配置文件获取DAL所在的命名空间
        private static readonly string path = ConfigurationManager.AppSettings["DAL"];

        private DataAccess() { }

        /// <summary>
        /// 创建UserRemarkDAL
        /// </summary>
        /// <returns></returns>
        public static IUserRemarkDAL CreateUserRemark()
        {
            string className = path + ".UserRemarkDAL";
            return (IUserRemarkDAL)Assembly.Load(path).CreateInstance(className);
        }
    }
}
